<template>
    <div>
        <detail-banner :name="bannerName" :img="bannerImg" :list="bannerList"></detail-banner>
        <detail-header></detail-header>
        <div class="content">
            <detail-list :list="list"></detail-list>
            <detail-comment :list="comment"></detail-comment>
        </div>
    </div>
</template>

<script>
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
import DetailComment from './components/Comment'

import axios from 'axios'

export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList,
    DetailComment
  },
  data () {
    return {
      bannerName: '',
      bannerImg: '',
      bannerList: [],
      list: [],
      comment: []
    }
  },
  methods: {
    getDetailInfo () {
      axios.get('/api/detail.json', {
        params: {
          id: this.$route.params.id
        }
      })
        .then(this.getDetailInfoSucc)
    },
    getDetailInfoSucc (res) {
      res = res.data
      if (res && res.ret) {
        var data = res.data
        this.bannerName = data.sightName
        this.bannerImg = data.bannerImg
        this.bannerList = data.gallaryImgs
        this.list = data.list
        this.comment = data.comment
      }
    }
  },
  mounted () {
    this.getDetailInfo()
  }
}
</script>

<style lang="stylus" scoped>
.content
  height 20rem
</style>
